from 算法.high.queue.queue import list_toqueue, print_que, ListNode

class Solution:
    def mergeKLists(self, lists):
        """
        :type lists: List[ListNode]
        :rtype: ListNode
        """
        if len(lists) == 0:
            return None
        value_list = []
        for node in lists:
            while node != None:
                value_list.append(node.val)
                node = node.next
        if len(value_list) == 0:
            return None
        if len(value_list) == 1:
            return ListNode(value_list[0])
        value_list.sort()
        top  = ListNode(value_list[0])
        q = top
        for value in value_list[1:]:
            q.next = ListNode(value)
            q = q.next
        return top